package httptools

import (
	"fmt"
	"github.com/goccy/go-json"
	"io"
	"net/http"
	"strings"
)

func Post(url string, body interface{}) []byte {
	marshal, _ := json.Marshal(body)

	resp, err := http.Post(url, "application/json", strings.NewReader(string(marshal)))
	if err != nil {
		fmt.Printf("DKAi回执出错啦～ %v\n", err.Error())
		return nil
	}

	defer func(Body io.ReadCloser) {
		_ = Body.Close()
	}(resp.Body)

	bodyBytes := resp.Body
	responseBody, _ := io.ReadAll(bodyBytes)

	fmt.Printf("报告主人，DKAi收到结果：%v\n", string(responseBody))
	return responseBody
}
